﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZFY.Core;

using ZFY.UMC.Model.Dto.UserClaim;

using ZFY.UMC.API.Repository;

using ZFY.DDD.Application;
using ZFY.UMC.BlazorWebAssembly.Shared.Dto;

namespace ZFY.UMC.API.Service
{
    public class UserClaimService: ApplicationService,IUserClaimService
    {
        private readonly IUserClaimRepository _userClaimRepository;

        public UserClaimService(IUserClaimRepository userClaimRepository)
            
        {
            _userClaimRepository = userClaimRepository;
        }

        public async Task<PageRequestOutput<GetUserClaimListOutput>> GetClaimListAsync(GetUserClaimListInput input)
        {
            var query = await _userClaimRepository.GetQueryableAsync();
            var count = await query.CountAsync();
            var list = await query.Skip((input.PageIndex - 1) * input.PageSize).Take(input.PageSize).ToListAsync();
            var dtoList = Mapper.Map<List<GetUserClaimListOutput>>(list);
            return new PageRequestOutput<GetUserClaimListOutput>(dtoList, count);
        }
    }
}
